package com.xiaoyi.springboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoyi.springboot.entity.CommonUser;
import com.xiaoyi.springboot.entity.SysUser;
import com.xiaoyi.springboot.mapper.CommonUserMapper;
import com.xiaoyi.springboot.service.CommonUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoyi
 * @since 2021-10-10
 */
@Service("commonUserService")
public class CommonUserServiceImpl extends ServiceImpl<CommonUserMapper, CommonUser> implements CommonUserService {
    @Autowired
    private CommonUserMapper commonUserMapper;

    @Override
    public CommonUser getUserByName(String username) {
        QueryWrapper<CommonUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_name",username);
        List<CommonUser> commonUsers = commonUserMapper.selectList(queryWrapper);
        return commonUsers.get(0);
    }
    @Override
    public CommonUser getUserByAccount(String account) {
        QueryWrapper<CommonUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_account",account);
        List<CommonUser> commonUsers = commonUserMapper.selectList(queryWrapper);
        return commonUsers.get(0);
    }
}
